from urllib.request import urlopen

from django.test import TestCase

# Create your tests here.
from urllib.parse import urlencode, parse_qs

# if __name__ == '__main__':
#     """字符串转化字典"""
#     qs_str = 'a=1&b=5&c=10'
#     qs_dict = parse_qs(qs_str)
#     print(qs_dict)


# if __name__ == '__main__':
#     """字典换为字符串"""
#     qs_dict = {'name': 'jing', 'age': 25}
#     qs_str = urlencode(qs_dict)
#     print(qs_str)


if __name__ == '__main__':
    """发起http请求"""
    url = 'http://api.meiduo.site:8000/usernames/15990386511/count/'
    response = urlopen(url)
    res_data = response.read()
    print(res_data.decode())
    